
#include "IClassBool.h"
#include "member_BClass.h"

using namespace BWE;

ClassBool::ClassBool() : BClass("bool", true)
{
	insertMethod("bool()", &ClassBool::create);
	insertMethod("bool(bool)", &ClassBool::create_bool);
	insertMethod("bool(char)", &ClassBool::create_char);
	insertMethod("bool(short)", &ClassBool::create_short);
	insertMethod("bool(int)", &ClassBool::create_int);
	insertMethod("bool(long)", &ClassBool::create_long);
	insertMethod("bool(real)", &ClassBool::create_real);
	insertMethod("bool(float)", &ClassBool::create_float);
	insertMethod("bool(double)", &ClassBool::create_double);

	insertMethod("bool =(bool)", &ClassBool::assign_bool);
	insertMethod("bool =(char)", &ClassBool::assign_char);
	insertMethod("bool =(short)", &ClassBool::assign_short);
	insertMethod("bool =(int)", &ClassBool::assign_int);
	insertMethod("bool =(long)", &ClassBool::assign_long);
	insertMethod("bool =(real)", &ClassBool::assign_real);
	insertMethod("bool =(float)", &ClassBool::assign_float);
	insertMethod("bool =(double)", &ClassBool::assign_double);

	insertMethod("bool &&(bool)", &ClassBool::logic_and);
	insertMethod("bool ||(bool)", &ClassBool::logic_not);

	insertMethod("bool ==(bool)", &ClassBool::equal_bool);
	insertMethod("bool ==(char)", &ClassBool::equal_char);
	insertMethod("bool ==(short)", &ClassBool::equal_short);
	insertMethod("bool ==(int)", &ClassBool::equal_int);
	insertMethod("bool ==(long)", &ClassBool::equal_long);
	insertMethod("bool ==(real)", &ClassBool::equal_real);
	insertMethod("bool ==(float)", &ClassBool::equal_float);
	insertMethod("bool ==(double)", &ClassBool::equal_double);

	insertMethod("bool !=(bool)", &ClassBool::unequal_bool);
	insertMethod("bool !=(char)", &ClassBool::unequal_char);
	insertMethod("bool !=(short)", &ClassBool::unequal_short);
	insertMethod("bool !=(int)", &ClassBool::unequal_int);
	insertMethod("bool !=(long)", &ClassBool::unequal_long);
	insertMethod("bool !=(real)", &ClassBool::unequal_real);
	insertMethod("bool !=(float)", &ClassBool::unequal_float);
	insertMethod("bool !=(double)", &ClassBool::unequal_double);

}

void ClassBool::create(int argc, BValue* argv)
{
	argv[0].refer() = false;
}
void ClassBool::create_bool(int argc, BValue* argv)
{
	bool b = argv[1];
	argv[0].refer() = b;
}
void ClassBool::create_char(int argc, BValue* argv)
{
	char c = argv[1];
	argv[0].refer() = (bool)c;
}
void ClassBool::create_short(int argc, BValue* argv)
{
	short s = argv[1];
	argv[0].refer() = (bool)s;
}
void ClassBool::create_int(int argc, BValue* argv)
{
	int i = argv[1];
	argv[0].refer() = (bool)i;
}
void ClassBool::create_long(int argc, BValue* argv)
{
	long long l = argv[1];
	argv[0].refer() = (bool)l;
}
void ClassBool::create_real(int argc, BValue* argv)
{
	BReal r = argv[1];
	argv[0].refer() = (bool)r;
}
void ClassBool::create_float(int argc, BValue* argv)
{
	float f = argv[1];
	argv[0].refer() = (bool)f;
}
void ClassBool::create_double(int argc, BValue* argv)
{
	double d = argv[1];
	argv[0].refer() = (bool)d;
}
void ClassBool::release(int argc, BValue* argv)
{
	argv[0].refer().clear();
}

void ClassBool::assign_bool(int argc, BValue* argv)
{
	bool& v = argv[0];
	bool b = argv[1];
	v = b;
}
void ClassBool::assign_char(int argc, BValue* argv)
{
	bool& v = argv[0];
	char c = argv[1];
	argv[0] = (bool)c;
}
void ClassBool::assign_short(int argc, BValue* argv)
{
	bool& v = argv[0];
	short s = argv[1];
	v = (bool)s;
}
void ClassBool::assign_int(int argc, BValue* argv)
{
	bool& v = argv[0];
	int i = argv[1];
	v = (bool)i;
}
void ClassBool::assign_long(int argc, BValue* argv)
{
	bool& v = argv[0];
	long long l = argv[1];
	v = (bool)l;
}
void ClassBool::assign_real(int argc, BValue* argv)
{
	bool& v = argv[0];
	BReal i = argv[1];
	v = (bool)i;
}
void ClassBool::assign_float(int argc, BValue* argv)
{
	bool& v = argv[0];
	float f = argv[1];
	v = (bool)f;
}
void ClassBool::assign_double(int argc, BValue* argv)
{
	bool& v = argv[0];
	double d = argv[1];
	v = (bool)d;
}

void ClassBool::logic_and(int argc, BValue* argv)
{
	bool v = argv[0];
	bool b = argv[1];
	argv[0] = (v && b);
}
void ClassBool::logic_not(int argc, BValue* argv)
{
	bool v = argv[0];
	bool b = argv[1];
	argv[0] = (v || b);
}

void ClassBool::equal_bool(int argc, BValue* argv)
{
	bool v = argv[0];
	bool b = argv[1];
	argv[0] = (v == b);
}
void ClassBool::equal_char(int argc, BValue* argv)
{
	bool v = argv[0];
	char c = argv[1];
	argv[0] = (v == (bool)c);
}
void ClassBool::equal_short(int argc, BValue* argv)
{
	bool v = argv[0];
	short s = argv[1];
	argv[0] = (v == (bool)s);
}
void ClassBool::equal_int(int argc, BValue* argv)
{
	bool v = argv[0];
	int i = argv[1];
	argv[0] = (v == (bool)i);
}
void ClassBool::equal_long(int argc, BValue* argv)
{
	bool v = argv[0];
	long long l = argv[1];
	argv[0] = (v == (bool)l);
}
void ClassBool::equal_real(int argc, BValue* argv)
{
	bool v = argv[0];
	BReal r = argv[1];
	argv[0] = (v == (bool)r);
}
void ClassBool::equal_float(int argc, BValue* argv)
{
	bool v = argv[0];
	float f = argv[1];
	argv[0] = (v == (bool)f);
}
void ClassBool::equal_double(int argc, BValue* argv)
{
	bool v = argv[0];
	double d = argv[1];
	argv[0] = (v == (bool)d);
}

void ClassBool::unequal_bool(int argc, BValue* argv)
{
	bool v = argv[0];
	bool b = argv[1];
	argv[0] = (v != b);
}
void ClassBool::unequal_char(int argc, BValue* argv)
{
	bool v = argv[0];
	char c = argv[1];
	argv[0] = (v != (bool)c);
}
void ClassBool::unequal_short(int argc, BValue* argv)
{
	bool v = argv[0];
	short s = argv[1];
	argv[0] = (v != (bool)s);
}
void ClassBool::unequal_int(int argc, BValue* argv)
{
	bool v = argv[0];
	int i = argv[1];
	argv[0] = (v != (bool)i);
}
void ClassBool::unequal_long(int argc, BValue* argv)
{
	bool v = argv[0];
	long long l = argv[1];
	argv[0] = (v != (bool)l);
}
void ClassBool::unequal_real(int argc, BValue* argv)
{
	bool v = argv[0];
	BReal r = argv[1];
	argv[0] = (v != (bool)r);
}
void ClassBool::unequal_float(int argc, BValue* argv)
{
	bool v = argv[0];
	float f = argv[1];
	argv[0] = (v != (bool)f);
}
void ClassBool::unequal_double(int argc, BValue* argv)
{
	bool v = argv[0];
	double d = argv[1];
	argv[0] = (v != (bool)d);
}
